using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using TidhiGanitam.DataModel;

namespace TidhiGanitam.Ganitam
{
    public class Budhudu
    {
        /*Rasi m_MadyamaRavi;
        Rasi m_RaviMandochha;
        Rasi m_RaviKendram;
        DateTime m_Ugadi;
        ArrayList m_DailyRoutines;
        */
        public Budhudu()
        {
          /*  m_MadyamaRavi = new Rasi();
            m_RaviMandochha = new Rasi();
            m_RaviKendram = new Rasi();
            m_DailyRoutines = new ArrayList();
           * */
        }
        public Budhudu(Rasi MadyamaBudhudu, Rasi BudhaMandochha)
        {
            /*
            m_MadyamaRavi = MadyamaRavi;
            m_RaviMandochha = RaviMandochha;
            m_DailyRoutines = new ArrayList();
             * */
        }
        /*
        public Rasi MadyamaRavi
        {
            get { return m_MadyamaRavi; }
        }
        public Rasi RaviMandochha
        {
            get { return m_RaviMandochha; }
        }
        public Rasi RaviKendram
        {
            get { return m_RaviKendram; }
        }
        public ArrayList DailyCalculations
        {
            get { return m_DailyRoutines; }
        }
         */
        public void DoBudhaSamskaram(int Year, Abdapudu abdapudu, YearDetails CurrentYearDetails)
        {
            
            /********************************************************
             * 1. Get MadyamaRavi, RaviMandochha for the Salivahana year
             * 2. These are Sayana Grahalu - With Iyanamsa
             * 3. Chalana Phala Samskaram
             * 4. Tidhula Samskaram
             * 5. Iyamamsa Samskaram
             * 6. Subtract RaviMandochha from MadyamaRavi = RaviKendram
             * *******************************************************/
            /*
            //First Note the Ugadi datetime
            m_Ugadi = abdapudu.UgadiDate;
            //Step 1 - Madyama Ravi, RaviMandochha for salivahana year
            RaviItem raviItem = SaliVahanaSakam.GetRaviValues(Year);
            m_MadyamaRavi = raviItem.MadyamaRavi;
            m_RaviMandochha = raviItem.RaviMandochha;

            //Step 3 - Chalana phala Samskaram
            //This is done only for MadyamaRavi
            Rasi TempChalanaPhalam = new Rasi(0,abdapudu.ChalanaPhalam.RawValue);
            Rasi chalanaPhalaValue = TempChalanaPhalam * Constants.RaviDinaGati;
            //ikkada / new Rasi(0, 0, 60, 0) vadiliveste correct value vacchindi
            //Round the chalanaphalam value
            chalanaPhalaValue = new Rasi(chalanaPhalaValue.Rasulu, chalanaPhalaValue.Bhagalu, chalanaPhalaValue.Liptalu, chalanaPhalaValue.Viliptalu);
            if (abdapudu.ChalanaPhalamSign == Enums.ChalanaPhalam.Runam)
            {
                m_MadyamaRavi -= chalanaPhalaValue;
            }
            else 
            {
                m_MadyamaRavi += chalanaPhalaValue;
            }

            //Step 4 - Tidhula Samskaram
            //This is done only for MadyamaRavi
            Rasi tidhulaGatiValue = Constants.RaviDinaGati * abdapudu.Tidhulu;
            m_MadyamaRavi -= tidhulaGatiValue;

            //Step 5 - Iyanamsa Samskaram
            //This is done for both MadyamaRavi and RaviMandochha

            m_MadyamaRavi -= CurrentYearDetails.UgadiIyanamsamu;
            m_RaviMandochha -= CurrentYearDetails.UgadiIyanamsamu;

            //Round the Madyama Ravi and Mandochha
            m_MadyamaRavi = m_MadyamaRavi.Round();
            m_RaviMandochha = m_RaviMandochha.Round();
            
            //Step 6 - Ravi Kendram
            // Subtract Ravi Mandochha from Madhyama Ravi.
            m_RaviKendram = m_MadyamaRavi - m_RaviMandochha;
            */
        }
        public void DoBudhaRoutinesForYear()
        {
            /*
            int iSNo = 0;
            ArrayList ArrRavi = new ArrayList();
            //The original RaviKendram is needed for calculations of chandra,
            //We take the copies of Ravi Kendram and Madyama Ravi and then proceed
            Rasi RaviKendram = new Rasi(m_RaviKendram);
            Rasi MadyamaRavi = new Rasi(m_MadyamaRavi);
            for (; iSNo < 400; iSNo++)
            {
                RaviRoutineItem RaviRoutine = new RaviRoutineItem(iSNo, RaviKendram, MadyamaRavi, m_Ugadi.AddDays(iSNo));
                RaviRoutine.Calculate();
                ArrRavi.Add(RaviRoutine);
                RaviKendram += Constants.RaviDinaGati;
                MadyamaRavi += Constants.RaviDinaGati;
                //Round values 
                RaviKendram.Refresh();
                MadyamaRavi.Refresh();
            }
            m_DailyRoutines = ArrRavi;
            */
        }
    }
}
